package com.treasure.mall.biz.service.core.community;

import com.treasure.mall.biz.base.SearchableCrudService;
import com.treasure.mall.biz.entity.community.CommunityArticleLikePO;
import com.treasure.mall.biz.entity.community.CommunityArticlePO;
import com.treasure.mall.biz.entity.community.CommunityCommentPO;
import com.treasure.mall.biz.entity.user.UserPO;
import com.treasure.mall.zbq.common.ienum.community.CommunityEnums;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;

/**
 * author：guomw
 */
public interface CommunityArticleService extends SearchableCrudService<CommunityArticlePO, Long> {
    /**
     * 评论
     *
     * @param articleId
     * @param userPO
     * @param content
     */
    CommunityCommentPO comment(Long articleId, UserPO userPO, String content);

    /**
     * 点赞或取消
     *
     * @param articleId
     * @param userPO
     */
    @Transactional
    boolean likeToggle(Long articleId, UserPO userPO);

    /**
     * 某个用户获赞的数量
     *
     * @param userId
     */
    long likeCount(Long userId);

    long countByUser(Long userId);

    long countByUserAudit(Long userId);

    /**
     * 我喜欢的内容列表
     *
     * @return
     */
    Page<CommunityArticleLikePO> likes(Long userId, int pageIndex, int pageSize);

    /**
     * 用户是否收藏（喜欢）
     *
     * @param articleId
     * @param userId
     * @return
     */
    boolean isUserLiked(Long articleId, Long userId);

    void delete(Long userId, Long articleId);

    /**
     * 修改访问量
     *
     * @param visitUser
     * @param articleId
     */
    @Transactional
    void modifyCommunityArticleVisit(UserPO visitUser, Long articleId);

    void modifyCommunityArticleAuditStatus(Long id, CommunityEnums.AuditStatus auditStatus, String reason);
}
